<template>
	<view class="chapter">
		<view style="text-align: center;margin-top: 160rpx;" v-if="isloding">
			<u-loading size="36"></u-loading>
		</view>
		<view class="list" v-if="!isloding">
			<view class="cell flex justify-between align-center" v-for="(item, index) in chapterList" :key="index"
				@click="handDetail(item)">
				<view class="title">{{ item.chaper_ }}</view>
				<view class="cell-right flex align-center">
					<text class="value">共{{ item.total_ }}题</text>
					<text class="lg cuIcon-right"></text>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	import {
		doChapter,
	} from '@/api/home.js'
	export default {
		data() {
			return {
				chapterList: [],
				isloding: true,
				city:''
			}
		},
		onLoad(options) {
			this.city = options.name
			this.getList()
		},
		methods: {
			handDetail(item) {
				uni.navigateTo({
					url: `/pages/paper/answer?type=1&id=${item.id_}&name=${item.chaper_}&city=${this.city}`
				})
			},
			async getList() {
				const {
					data
				} = await doChapter({
					city: this.city
				})
				this.chapterList = data
				this.isloding = false
			}
		}
	}
</script>

<style lang="scss" scoped>
	.chapter {
		min-height: 100vh;
		background-color: #F5F6F9;
		overflow: hidden;

		.list {
			padding-top: 40rpx;

			.cell {
				width: 702rpx;
				background: #FFFFFF;
				border-radius: 20rpx;
				margin: 0 auto 0 auto;
				padding: 20rpx;

				&:not(:first-child) {
					margin-top: 20rpx;
				}

				.title {
					flex: 1;
					font-size: 34rpx;
					line-height: 51rpx;
					font-family: PingFang SC;
					font-weight: 400;
					color: #2D3341;
				}

				&-right {
					margin-left: 80rpx;

					.value {
						font-size: 30rpx;
						font-family: PingFang SC;
						font-weight: 400;
						color: #838A9D;
					}

					.cuIcon-right {
						margin-left: 5rpx;
						color: #060606;
					}
				}
			}

		}
	}
</style>